<?php


class Correlations {
	
	private $dbconn;
	
	public function Correlations($dbconn) {
		$this->dbconn = $dbconn;
	}
	
	public function getAllCorrelations($userid) {
		$query = "SELECT * FROM correlations WHERE userid='".$userid."'";
		$res = mysql_query($query, $this->dbconn);
		$ret = array();
		$ret["userid"] = $userid;
		while($row = mysql_fetch_assoc($res)) {
			$ret[$row["var1"]][$row["var2"]] = $row["value"]; 
		}
		return $ret;
	}
	
	public function getCorrelation($userid, $var1, $var2) {
		$query = "SELECT * FROM correlations WHERE userid='".$userid."' AND var1='".$var1."' AND var2='".$var2."';";
		$res = mysql_query($query, $this->dbconn);
		return mysql_fetch_assoc($res);
	}
}